\(\int \csc ^2(c+d x) \sec ^2(c+d x) (a+b \sin (c+d x))^2 \, dx\) [1454]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [F(-1)]
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 29, antiderivative size = 59 \[ \int \csc ^2(c+d x) \sec ^2(c+d x) (a+b \sin (c+d x))^2 \, dx=-\frac {2 a b \text {arctanh}(\cos (c+d x))}{d}-\frac {a^2 \cot (c+d x)}{d}+\frac {2 a b \sec (c+d x)}{d}+\frac {\left (a^2+b^2\right ) \tan (c+d x)}{d} \]

[Out]

-2*a*b*arctanh(cos(d*x+c))/d-a^2*cot(d*x+c)/d+2*a*b*sec(d*x+c)/d+(a^2+b^2)*tan(d*x+c)/d

Rubi [A] (verified)

Time = 0.19 (sec) , antiderivative size = 59, normalized size of antiderivative = 1.00, number of steps used = 7, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.207, Rules used = {2990, 2702, 327, 213, 3279, 14} \[ \int \csc ^2(c+d x) \sec ^2(c+d x) (a+b \sin (c+d x))^2 \, dx=\frac {\left (a^2+b^2\right ) \tan (c+d x)}{d}-\frac {a^2 \cot (c+d x)}{d}-\frac {2 a b \text {arctanh}(\cos (c+d x))}{d}+\frac {2 a b \sec (c+d x)}{d} \]

[In]

Int[Csc[c + d*x]^2*Sec[c + d*x]^2*(a + b*Sin[c + d*x])^2,x]

[Out]

(-2*a*b*ArcTanh[Cos[c + d*x]])/d - (a^2*Cot[c + d*x])/d + (2*a*b*Sec[c + d*x])/d + ((a^2 + b^2)*Tan[c + d*x])/
d

Rule 14

Int[(u_)*((c_.)*(x_))^(m_.), x_Symbol] :> Int[ExpandIntegrand[(c*x)^m*u, x], x] /; FreeQ[{c, m}, x] && SumQ[u]
 &&  !LinearQ[u, x] &&  !MatchQ[u, (a_) + (b_.)*(v_) /; FreeQ[{a, b}, x] && InverseFunctionQ[v]]

Rule 213

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(-(Rt[-a, 2]*Rt[b, 2])^(-1))*ArcTanh[Rt[b, 2]*(x/Rt[-a, 2])]
, x] /; FreeQ[{a, b}, x] && NegQ[a/b] && (LtQ[a, 0] || GtQ[b, 0])

Rule 327

Int[((c_.)*(x_))^(m_)*((a_) + (b_.)*(x_)^(n_))^(p_), x_Symbol] :> Simp[c^(n - 1)*(c*x)^(m - n + 1)*((a + b*x^n
)^(p + 1)/(b*(m + n*p + 1))), x] - Dist[a*c^n*((m - n + 1)/(b*(m + n*p + 1))), Int[(c*x)^(m - n)*(a + b*x^n)^p
, x], x] /; FreeQ[{a, b, c, p}, x] && IGtQ[n, 0] && GtQ[m, n - 1] && NeQ[m + n*p + 1, 0] && IntBinomialQ[a, b,
 c, n, m, p, x]

Rule 2702

Int[csc[(e_.) + (f_.)*(x_)]^(n_.)*((a_.)*sec[(e_.) + (f_.)*(x_)])^(m_), x_Symbol] :> Dist[1/(f*a^n), Subst[Int
[x^(m + n - 1)/(-1 + x^2/a^2)^((n + 1)/2), x], x, a*Sec[e + f*x]], x] /; FreeQ[{a, e, f, m}, x] && IntegerQ[(n
 + 1)/2] &&  !(IntegerQ[(m + 1)/2] && LtQ[0, m, n])

Rule 2990

Int[(cos[(e_.) + (f_.)*(x_)]*(g_.))^(p_)*((d_.)*sin[(e_.) + (f_.)*(x_)])^(n_)*((a_) + (b_.)*sin[(e_.) + (f_.)*
(x_)])^2, x_Symbol] :> Dist[2*a*(b/d), Int[(g*Cos[e + f*x])^p*(d*Sin[e + f*x])^(n + 1), x], x] + Int[(g*Cos[e
+ f*x])^p*(d*Sin[e + f*x])^n*(a^2 + b^2*Sin[e + f*x]^2), x] /; FreeQ[{a, b, d, e, f, g, n, p}, x] && NeQ[a^2 -
 b^2, 0]

Rule 3279

Int[cos[(e_.) + (f_.)*(x_)]^(m_)*sin[(e_.) + (f_.)*(x_)]^(n_)*((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)]^2)^(p_.),
x_Symbol] :> With[{ff = FreeFactors[Tan[e + f*x], x]}, Dist[ff^(n + 1)/f, Subst[Int[x^n*((a + (a + b)*ff^2*x^2
)^p/(1 + ff^2*x^2)^((m + n)/2 + p + 1)), x], x, Tan[e + f*x]/ff], x]] /; FreeQ[{a, b, e, f}, x] && IntegerQ[m/
2] && IntegerQ[n/2] && IntegerQ[p]

Rubi steps \begin{align*} \text {integral}& = (2 a b) \int \csc (c+d x) \sec ^2(c+d x) \, dx+\int \csc ^2(c+d x) \sec ^2(c+d x) \left (a^2+b^2 \sin ^2(c+d x)\right ) \, dx \\ & = \frac {\text {Subst}\left (\int \frac {a^2+\left (a^2+b^2\right ) x^2}{x^2} \, dx,x,\tan (c+d x)\right )}{d}+\frac {(2 a b) \text {Subst}\left (\int \frac {x^2}{-1+x^2} \, dx,x,\sec (c+d x)\right )}{d} \\ & = \frac {2 a b \sec (c+d x)}{d}+\frac {\text {Subst}\left (\int \left (a^2 \left (1+\frac {b^2}{a^2}\right )+\frac {a^2}{x^2}\right ) \, dx,x,\tan (c+d x)\right )}{d}+\frac {(2 a b) \text {Subst}\left (\int \frac {1}{-1+x^2} \, dx,x,\sec (c+d x)\right )}{d} \\ & = -\frac {2 a b \text {arctanh}(\cos (c+d x))}{d}-\frac {a^2 \cot (c+d x)}{d}+\frac {2 a b \sec (c+d x)}{d}+\frac {\left (a^2+b^2\right ) \tan (c+d x)}{d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.92 (sec) , antiderivative size = 102, normalized size of antiderivative = 1.73 \[ \int \csc ^2(c+d x) \sec ^2(c+d x) (a+b \sin (c+d x))^2 \, dx=-\frac {\csc \left (\frac {1}{2} (c+d x)\right ) \sec \left (\frac {1}{2} (c+d x)\right ) \sec (c+d x) \left (\left (2 a^2+b^2\right ) \cos (2 (c+d x))-b \left (b+4 a \sin (c+d x)-2 a \left (\log \left (\cos \left (\frac {1}{2} (c+d x)\right )\right )-\log \left (\sin \left (\frac {1}{2} (c+d x)\right )\right )\right ) \sin (2 (c+d x))\right )\right )}{4 d} \]

[In]

Integrate[Csc[c + d*x]^2*Sec[c + d*x]^2*(a + b*Sin[c + d*x])^2,x]

[Out]

-1/4*(Csc[(c + d*x)/2]*Sec[(c + d*x)/2]*Sec[c + d*x]*((2*a^2 + b^2)*Cos[2*(c + d*x)] - b*(b + 4*a*Sin[c + d*x]
 - 2*a*(Log[Cos[(c + d*x)/2]] - Log[Sin[(c + d*x)/2]])*Sin[2*(c + d*x)])))/d

Maple [A] (verified)

Time = 0.77 (sec) , antiderivative size = 75, normalized size of antiderivative = 1.27

method result size
derivativedivides \(\frac {a^{2} \left (\frac {1}{\sin \left (d x +c \right ) \cos \left (d x +c \right )}-2 \cot \left (d x +c \right )\right )+2 a b \left (\frac {1}{\cos \left (d x +c \right )}+\ln \left (\csc \left (d x +c \right )-\cot \left (d x +c \right )\right )\right )+b^{2} \tan \left (d x +c \right )}{d}\) \(75\)
default \(\frac {a^{2} \left (\frac {1}{\sin \left (d x +c \right ) \cos \left (d x +c \right )}-2 \cot \left (d x +c \right )\right )+2 a b \left (\frac {1}{\cos \left (d x +c \right )}+\ln \left (\csc \left (d x +c \right )-\cot \left (d x +c \right )\right )\right )+b^{2} \tan \left (d x +c \right )}{d}\) \(75\)
parallelrisch \(\frac {4 a b \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )-1\right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\left (\tan ^{3}\left (\frac {d x}{2}+\frac {c}{2}\right )\right ) a^{2}+2 \left (-3 a^{2}-2 b^{2}\right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )+a \left (a \cot \left (\frac {d x}{2}+\frac {c}{2}\right )-8 b \right )}{2 d \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}\) \(103\)
risch \(\frac {2 i b^{2} {\mathrm e}^{2 i \left (d x +c \right )}+4 a b \,{\mathrm e}^{3 i \left (d x +c \right )}-4 i a^{2}-2 i b^{2}-4 a b \,{\mathrm e}^{i \left (d x +c \right )}}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right ) \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}-\frac {2 a b \ln \left ({\mathrm e}^{i \left (d x +c \right )}+1\right )}{d}+\frac {2 a b \ln \left ({\mathrm e}^{i \left (d x +c \right )}-1\right )}{d}\) \(125\)
norman \(\frac {\frac {a^{2}}{2 d}+\frac {a^{2} \left (\tan ^{8}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{2 d}-\frac {2 \left (a^{2}+b^{2}\right ) \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d}-\frac {2 \left (a^{2}+b^{2}\right ) \left (\tan ^{6}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d}-\frac {\left (5 a^{2}+4 b^{2}\right ) \left (\tan ^{4}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d}-\frac {4 a b \left (\tan ^{5}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d}-\frac {4 a b \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{d}-\frac {8 a b \left (\tan ^{3}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d}}{\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )-1\right ) \left (1+\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )^{2}}+\frac {2 a b \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d}\) \(214\)

[In]

int(csc(d*x+c)^2*sec(d*x+c)^2*(a+b*sin(d*x+c))^2,x,method=_RETURNVERBOSE)

[Out]

1/d*(a^2*(1/sin(d*x+c)/cos(d*x+c)-2*cot(d*x+c))+2*a*b*(1/cos(d*x+c)+ln(csc(d*x+c)-cot(d*x+c)))+b^2*tan(d*x+c))

Fricas [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 113, normalized size of antiderivative = 1.92 \[ \int \csc ^2(c+d x) \sec ^2(c+d x) (a+b \sin (c+d x))^2 \, dx=-\frac {a b \cos \left (d x + c\right ) \log \left (\frac {1}{2} \, \cos \left (d x + c\right ) + \frac {1}{2}\right ) \sin \left (d x + c\right ) - a b \cos \left (d x + c\right ) \log \left (-\frac {1}{2} \, \cos \left (d x + c\right ) + \frac {1}{2}\right ) \sin \left (d x + c\right ) + {\left (2 \, a^{2} + b^{2}\right )} \cos \left (d x + c\right )^{2} - 2 \, a b \sin \left (d x + c\right ) - a^{2} - b^{2}}{d \cos \left (d x + c\right ) \sin \left (d x + c\right )} \]

[In]

integrate(csc(d*x+c)^2*sec(d*x+c)^2*(a+b*sin(d*x+c))^2,x, algorithm="fricas")

[Out]

-(a*b*cos(d*x + c)*log(1/2*cos(d*x + c) + 1/2)*sin(d*x + c) - a*b*cos(d*x + c)*log(-1/2*cos(d*x + c) + 1/2)*si
n(d*x + c) + (2*a^2 + b^2)*cos(d*x + c)^2 - 2*a*b*sin(d*x + c) - a^2 - b^2)/(d*cos(d*x + c)*sin(d*x + c))

Sympy [F(-1)]

Timed out. \[ \int \csc ^2(c+d x) \sec ^2(c+d x) (a+b \sin (c+d x))^2 \, dx=\text {Timed out} \]

[In]

integrate(csc(d*x+c)**2*sec(d*x+c)**2*(a+b*sin(d*x+c))**2,x)

[Out]

Timed out

Maxima [A] (verification not implemented)

none

Time = 0.20 (sec) , antiderivative size = 71, normalized size of antiderivative = 1.20 \[ \int \csc ^2(c+d x) \sec ^2(c+d x) (a+b \sin (c+d x))^2 \, dx=\frac {a b {\left (\frac {2}{\cos \left (d x + c\right )} - \log \left (\cos \left (d x + c\right ) + 1\right ) + \log \left (\cos \left (d x + c\right ) - 1\right )\right )} - a^{2} {\left (\frac {1}{\tan \left (d x + c\right )} - \tan \left (d x + c\right )\right )} + b^{2} \tan \left (d x + c\right )}{d} \]

[In]

integrate(csc(d*x+c)^2*sec(d*x+c)^2*(a+b*sin(d*x+c))^2,x, algorithm="maxima")

[Out]

(a*b*(2/cos(d*x + c) - log(cos(d*x + c) + 1) + log(cos(d*x + c) - 1)) - a^2*(1/tan(d*x + c) - tan(d*x + c)) +
b^2*tan(d*x + c))/d

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 128 vs. \(2 (59) = 118\).

Time = 0.61 (sec) , antiderivative size = 128, normalized size of antiderivative = 2.17 \[ \int \csc ^2(c+d x) \sec ^2(c+d x) (a+b \sin (c+d x))^2 \, dx=\frac {12 \, a b \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) \right |}\right ) + 3 \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - \frac {4 \, a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 15 \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 12 \, b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 20 \, a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 3 \, a^{2}}{\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}}{6 \, d} \]

[In]

integrate(csc(d*x+c)^2*sec(d*x+c)^2*(a+b*sin(d*x+c))^2,x, algorithm="giac")

[Out]

1/6*(12*a*b*log(abs(tan(1/2*d*x + 1/2*c))) + 3*a^2*tan(1/2*d*x + 1/2*c) - (4*a*b*tan(1/2*d*x + 1/2*c)^3 + 15*a
^2*tan(1/2*d*x + 1/2*c)^2 + 12*b^2*tan(1/2*d*x + 1/2*c)^2 + 20*a*b*tan(1/2*d*x + 1/2*c) - 3*a^2)/(tan(1/2*d*x
+ 1/2*c)^3 - tan(1/2*d*x + 1/2*c)))/d

Mupad [B] (verification not implemented)

Time = 11.46 (sec) , antiderivative size = 108, normalized size of antiderivative = 1.83 \[ \int \csc ^2(c+d x) \sec ^2(c+d x) (a+b \sin (c+d x))^2 \, dx=\frac {{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2\,\left (5\,a^2+4\,b^2\right )-a^2+8\,a\,b\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{d\,\left (2\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )-2\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^3\right )}+\frac {a^2\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{2\,d}+\frac {2\,a\,b\,\ln \left (\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\right )}{d} \]

[In]

int((a + b*sin(c + d*x))^2/(cos(c + d*x)^2*sin(c + d*x)^2),x)

[Out]

(tan(c/2 + (d*x)/2)^2*(5*a^2 + 4*b^2) - a^2 + 8*a*b*tan(c/2 + (d*x)/2))/(d*(2*tan(c/2 + (d*x)/2) - 2*tan(c/2 +
 (d*x)/2)^3)) + (a^2*tan(c/2 + (d*x)/2))/(2*d) + (2*a*b*log(tan(c/2 + (d*x)/2)))/d